"use strict";
const e = require("../../common/vendor.js"),
  a = require("../../api/request.js"),
  u = {
    __name: "password",
    setup(u) {
      const l = e.ref(""),
        v = e.ref(""),
        r = e.ref(""),
        t = e.ref(""),
        o = e.ref(!1),
        s = e.ref(60),
        c = e.ref("发送验证码"),
        n = e.ref("");
      async function i() {
        const e = await a.requestApi("/vercode", {
          phoneNumbers: l.value
        });
        n.value = e.data.bizId, o.value = !0;
        var u = setInterval((() => {
          s.value > 1 ? (s.value--, c.value = `${s.value}秒后重新获取`) : (clearInterval(u), o.value = !1, s.value = 60, c.value = "发送验证码")
        }), 1e3)
      }
      const d = e.ref(""),
        f = e.ref(!1);
      e.watchEffect((() => {
        r.value === t.value ? (d.value = "", f.value = !1) : (d.value = "两次输入的密码不一致", f.value = !0)
      }));
      const p = e.ref(!1);
      async function w() {
        try {
          p.value = !0, await a.requestApi("/upload_password", {
            mobile: l.value,
            code: v.value,
            bizId: n.value,
            password: r.value
          }, "POST"), p.value = !1, e.index.navigateBack({
            delta: 1
          })
        } catch (u) {
          p.value = !1
        }
      }
      return (a, u) => ({
        a: l.value,
        b: e.o((e => l.value = e.detail.value)),
        c: v.value,
        d: e.o((e => v.value = e.detail.value)),
        e: e.t(c.value),
        f: o.value,
        g: e.o(i),
        h: r.value,
        i: e.o((e => r.value = e.detail.value)),
        j: t.value,
        k: e.o((e => t.value = e.detail.value)),
        l: e.t(d.value),
        m: e.o(w),
        n: p.value,
        o: f.value
      })
    }
  };
wx.createPage(u);